package exception;
//finally保证只要程序执行到try块中,无论try是否发生异常,finally都执行
public class FinallyDemo {
    public static void main(String[] args) {
        System.out.println("程序开始了");

        try{
            //String str = null;
            String str = "abc";
            System.out.println(str.length());
            return;//先执行finally的代码再结束方法
        }catch(Exception e){
            System.out.println("出错了");
        }finally{
            System.out.println("finally执行了");
        }

        System.out.println("程序结束了");

    }
}
